IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_dossierContracten' AND xtype='P') 
BEGIN
	DROP PROCEDURE WEB_dossierContracten
END
GO

CREATE   procedure WEB_dossierContracten
(@hoofdNr int,@iNr char(7))
as
set nocount on
if exists(select * from deContracten where inschrijvingsNr = @iNr)
begin
  select @hoofdNr as hoofdNr,0 as volgNr,'<extraTeksten>' as tekst
    union
  select @hoofdNr,1,
   '<extra>' + 
   '<volgNr>' + convert(varchar(15),volgNr) + '</volgNr>' +
   '<titel>'+ isNull(jaar,'')+' '+ isNull(titel,'')+'</titel>' +
   '<aard>' + isNull(aard,'') + '</aard>' + '</extra>'
   from deContracten
   where inschrijvingsNr = @iNr
    union
  select @hoofdNr,2,'</extraTeksten>'
end